home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vssexa1a / frmvss.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-08-27  |  10.1 KB  |  335 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   7230
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   6585
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   7230
  10.    ScaleWidth      =   6585
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.Frame Frame2 
  13.       Caption         =   "Files"
  14.       Height          =   2415
  15.       Left            =   120
  16.       TabIndex        =   10
  17.       Top             =   4680
  18.       Width           =   6375
  19.       Begin VB.ListBox lstFiles 
  20.          Height          =   2010
  21.          Left            =   120
  22.          MultiSelect     =   2  'Extended
  23.          TabIndex        =   12
  24.          Top             =   240
  25.          Width           =   4575
  26.       End
  27.       Begin VB.CommandButton cmdGetFile 
  28.          Caption         =   "Get &File"
  29.          Enabled         =   0   'False
  30.          Height          =   495
  31.          Left            =   4920
  32.          TabIndex        =   11
  33.          Top             =   240
  34.          Width           =   1215
  35.       End
  36.    End
  37.    Begin VB.Frame Frame1 
  38.       Caption         =   "Projects"
  39.       Height          =   2415
  40.       Left            =   120
  41.       TabIndex        =   8
  42.       Top             =   2160
  43.       Width           =   6375
  44.       Begin VB.CommandButton cmdGetProject 
  45.          Caption         =   "Get &Project"
  46.          Enabled         =   0   'False
  47.          Height          =   495
  48.          Left            =   4920
  49.          TabIndex        =   14
  50.          Top             =   240
  51.          Width           =   1215
  52.       End
  53.       Begin VB.CheckBox chkSubFolders 
  54.          Caption         =   "Show files in sub folders"
  55.          Height          =   375
  56.          Left            =   4800
  57.          TabIndex        =   13
  58.          Top             =   1920
  59.          Width           =   1455
  60.       End
  61.       Begin VB.ListBox lstProjects 
  62.          Height          =   2010
  63.          Left            =   120
  64.          MultiSelect     =   2  'Extended
  65.          TabIndex        =   9
  66.          Top             =   240
  67.          Width           =   4575
  68.       End
  69.    End
  70.    Begin VB.CommandButton cmdExit 
  71.       Caption         =   "E&xit"
  72.       Height          =   495
  73.       Left            =   5040
  74.       TabIndex        =   7
  75.       Top             =   1440
  76.       Width           =   1215
  77.    End
  78.    Begin VB.CommandButton cmdOpen 
  79.       Caption         =   "&Open VSS"
  80.       Height          =   495
  81.       Left            =   240
  82.       TabIndex        =   6
  83.       Top             =   1440
  84.       Width           =   1215
  85.    End
  86.    Begin VB.TextBox txtPassword 
  87.       Height          =   285
  88.       IMEMode         =   3  'DISABLE
  89.       Left            =   2160
  90.       PasswordChar    =   "*"
  91.       TabIndex        =   5
  92.       Top             =   960
  93.       Width           =   4095
  94.    End
  95.    Begin VB.TextBox txtUserID 
  96.       Height          =   285
  97.       Left            =   2160
  98.       TabIndex        =   3
  99.       Top             =   600
  100.       Width           =   4095
  101.    End
  102.    Begin VB.TextBox txtINIPath 
  103.       Height          =   285
  104.       Left            =   2160
  105.       TabIndex        =   1
  106.       Top             =   240
  107.       Width           =   4095
  108.    End
  109.    Begin VB.Label Label2 
  110.       Alignment       =   1  'Right Justify
  111.       Caption         =   "Password:"
  112.       Height          =   255
  113.       Left            =   240
  114.       TabIndex        =   4
  115.       Top             =   960
  116.       Width           =   1695
  117.    End
  118.    Begin VB.Label Label1 
  119.       Alignment       =   1  'Right Justify
  120.       Caption         =   "User ID:"
  121.       Height          =   255
  122.       Left            =   240
  123.       TabIndex        =   2
  124.       Top             =   600
  125.       Width           =   1695
  126.    End
  127.    Begin VB.Label lblPath 
  128.       Alignment       =   1  'Right Justify
  129.       Caption         =   "srcsafe.ini Path:"
  130.       Height          =   255
  131.       Left            =   240
  132.       TabIndex        =   0
  133.       Top             =   240
  134.       Width           =   1695
  135.    End
  136. Attribute VB_Name = "Form1"
  137. Attribute VB_GlobalNameSpace = False
  138. Attribute VB_Creatable = False
  139. Attribute VB_PredeclaredId = True
  140. Attribute VB_Exposed = False
  141. Option Explicit
  142. '*************************************************
  143. 'Date: 08/27/99 mg
  144. 'We have weekly (sometimes daily) builds of the
  145. 'software we are developing.  We have a build process
  146. 'that I have (for the most part) automated.  The only
  147. 'piece missing was the ability to interact with
  148. 'SourceSafe and get the files the developers wanted
  149. 'added to the build.  This project reads a source safe
  150. 'database and gets projects and files from it.  There
  151. 'is a MS article at
  152. ' http://msdn.microsoft.com/SSAFE/technical/articles/vssauto/VSSAuto.html
  153. 'that gives functionality
  154. 'possibilites that could be added.  If you have any
  155. 'questions, don't hesitate to send me an email.
  156. '*************************************************
  157. Dim vsdb As New VSSDatabase
  158. Dim vsItem As VSSItem
  159. Dim loopItem As VSSItem
  160. Dim tabcount As Integer
  161. Dim vsProjects() As String
  162. Dim vsProjectSpecifics() As String
  163. Private Sub cmdExit_Click()
  164.   Unload Me
  165.   End
  166. End Sub
  167. Private Sub cmdGetFile_Click()
  168. Dim j%
  169.     '
  170.     'loop through the list to get all selected
  171.     '
  172.   For j = 0 To lstFiles.ListCount - 1
  173.     If lstFiles.Selected(j) = True Then
  174.         '
  175.         'set the db current project to the selected file
  176.         '
  177.       vsdb.CurrentProject = vsProjectSpecifics(j + 1)
  178.         '
  179.         'set the item
  180.         '
  181.       Set vsItem = vsdb.VSSItem(vsdb.CurrentProject, False)
  182.         '
  183.         'get the file
  184.         '
  185.       vsItem.Get
  186.     End If
  187.   Next 'j
  188. End Sub
  189. Private Sub cmdGetProject_Click()
  190. Dim j%
  191.     '
  192.     'loop through the list to get all selected
  193.     '
  194.   For j = 0 To lstProjects.ListCount - 1
  195.     If lstProjects.Selected(j) = True Then
  196.         '
  197.         'set the db current project to the selected file
  198.         '
  199.       vsdb.CurrentProject = vsProjects(j + 1)
  200.         '
  201.         'set the item
  202.         '
  203.       Set vsItem = vsdb.VSSItem(vsdb.CurrentProject, False)
  204.         '
  205.         'get the project
  206.         '
  207.       vsItem.Get
  208.     End If
  209.   Next 'j
  210. End Sub
  211. Private Sub cmdOpen_Click()
  212. Dim tmp$
  213.     '
  214.     'open a connection to the emerald database
  215.     '
  216.   If Right$(txtINIPath.Text, 1) <> "\" Then
  217.     vsdb.Open txtINIPath.Text & "\srcsafe.ini", txtUserID.Text, txtPassword.Text
  218.   Else
  219.     vsdb.Open txtINIPath.Text & "srcsafe.ini", txtUserID.Text, txtPassword.Text
  220.   End If
  221.     '
  222.     'look at the root project
  223.     '
  224.   vsdb.CurrentProject = "$/"
  225.   tabcount = -1
  226.   Call GetProjects(vsdb.CurrentProject)
  227. End Sub
  228. Sub GetProjectSpecifics(ProjectName$, Recursion As Boolean)
  229. Dim gpfItem As VSSItem
  230. Dim gpfLoop As VSSItem
  231. Dim tmp$
  232.   tabcount = tabcount + 1
  233.   Set gpfItem = vsdb.VSSItem(ProjectName$, False)
  234.     '
  235.     'loop thru the items and add the names to a list box
  236.     '
  237.   For Each gpfLoop In gpfItem.Items(False)
  238.     tmp$ = String$(tabcount, Chr$(9))
  239.     If gpfLoop.Type = VSSITEM_PROJECT Then
  240.         '
  241.         'add to the list and add to the project array
  242.         '
  243.       lstFiles.AddItem tmp$ & gpfLoop.Name
  244.       ReDim Preserve vsProjectSpecifics(UBound(vsProjectSpecifics) + 1)
  245.       vsProjectSpecifics(UBound(vsProjectSpecifics)) = gpfLoop.Spec
  246.       lstFiles.ItemData(lstFiles.NewIndex) = UBound(vsProjectSpecifics)
  247.       If Recursion = True Then
  248.           '
  249.           'loop through any folders in this folder
  250.           '
  251.         If Right$(ProjectName$, 1) = "/" Then
  252.           Call GetProjectSpecifics(ProjectName$ & gpfLoop.Name, Recursion)
  253.         Else
  254.           Call GetProjectSpecifics(ProjectName$ & "/" & gpfLoop.Name, Recursion)
  255.         End If
  256.       End If
  257.     ElseIf gpfLoop.Type = VSSITEM_FILE Then
  258.         '
  259.         'add to the list and add to the project array
  260.         '
  261.       lstFiles.AddItem tmp$ & gpfLoop.Name
  262.       ReDim Preserve vsProjectSpecifics(UBound(vsProjectSpecifics) + 1)
  263.       vsProjectSpecifics(UBound(vsProjectSpecifics)) = gpfLoop.Spec
  264.       lstFiles.ItemData(lstFiles.NewIndex) = UBound(vsProjectSpecifics)
  265.     End If
  266.   Next
  267.   tabcount = tabcount - 1
  268. End Sub
  269. Sub GetProjects(ProjectName$)
  270. Dim gpfItem As VSSItem
  271. Dim gpfLoop As VSSItem
  272. Dim tmp$
  273.   tabcount = tabcount + 1
  274.   Set gpfItem = vsdb.VSSItem(ProjectName$, False)
  275.     '
  276.     'loop thru the items and add the names to a list box
  277.     '
  278.   For Each gpfLoop In gpfItem.Items(False)
  279.     tmp$ = String$(tabcount, Chr$(9))
  280.     If gpfLoop.Type = VSSITEM_PROJECT Then
  281.         '
  282.         'add to the list and add to the project array
  283.         '
  284.       lstProjects.AddItem tmp$ & gpfLoop.Name
  285.       ReDim Preserve vsProjects(UBound(vsProjects) + 1)
  286.       vsProjects(UBound(vsProjects)) = gpfLoop.Spec
  287.       lstProjects.ItemData(lstProjects.NewIndex) = UBound(vsProjects)
  288.         '
  289.         'loop through any folders in this folder
  290.         '
  291.       If Right$(ProjectName$, 1) = "/" Then
  292.         Call GetProjects(ProjectName$ & gpfLoop.Name)
  293.       Else
  294.         Call GetProjects(ProjectName$ & "/" & gpfLoop.Name)
  295.       End If
  296.     End If
  297.   Next
  298.   tabcount = tabcount - 1
  299. End Sub
  300. Private Sub Form_Load()
  301.   ReDim vsProjects$(0)
  302.   ReDim vsProjectSpecifics$(0)
  303. End Sub
  304. Private Sub Form_Unload(Cancel As Integer)
  305. On Error Resume Next
  306.   Set vsdb = Nothing
  307. End Sub
  308. Private Sub lstFiles_Click()
  309.   cmdGetFile.Enabled = True
  310. End Sub
  311. Private Sub lstProjects_Click()
  312.   cmdGetProject.Enabled = True
  313. End Sub
  314. Private Sub lstProjects_DblClick()
  315.     '
  316.     'if the user clicks on a project, list all the files
  317.     'for that project
  318.     '
  319.   vsdb.CurrentProject = vsProjects(lstProjects.ListIndex + 1)
  320.   Set vsItem = vsdb.VSSItem(vsdb.CurrentProject, False)
  321.     '
  322.     'clear the previous files
  323.     '
  324.   lstFiles.Clear
  325.   cmdGetFile.Enabled = False
  326.     '
  327.     'get sub folders if the user so desires
  328.     '
  329.   If chkSubFolders.Value = vbChecked Then
  330.     Call GetProjectSpecifics(vsProjects(lstProjects.ListIndex + 1), True)
  331.   Else
  332.     Call GetProjectSpecifics(vsProjects(lstProjects.ListIndex + 1), False)
  333.   End If
  334. End Sub
  335.